<%+header%>
<%
luci.sys.call("/etc/init.d/openmptcprouter-vps backup_list >/dev/null 2>/dev/null")
local ucic  = luci.model.uci.cursor()
menuentry = ucic:get("openmptcprouter","settings","menu") or "openmptcprouter"
%>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
<form class="inline" method="post" action="<%=url('admin/system/' .. menuentry:lower() .. '/backupgr')%>">
    <div class="cbi-map">
	<h2 name="content"><%:Backup on server%></h2>
	<fieldset class="cbi-section" id="networks">
		<input type="hidden" name="token" value="<%=token%>" />
		<%
		    uci:foreach("openmptcprouter","server", function(s)
			servername = s[".name"]
		%>
		<h3><%=servername%></h3>
		<%
		    if luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup") ~= nil then
		%>
			<div class="cbi-section-node">
				<%:Last available backup on server:%> <%=os.date('%d-%b-%Y', luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup"))%>
			</div>
		<% else %>
			<div class="cbi-section-node">
				<%:No available backup on server.%>
			</div>
		<% end %>
	    <%
		end)
	    %>
		<input type="submit" class="cbi-button cbi-button-action important" name="restore" value="<%:Restore backup%>"/>
		<input type="submit" class="cbi-button cbi-button-action important" name="save" value="<%:Send backup%>"/>

	</fieldset>
    </div>
</form>
<%+footer%>
